<!DOCTYPE html>
<html lang="en" style="height:100%;">
<head>
	<meta charset="UTF-8" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no,minimal-ui">
	<title>注册</title>
	<link rel="stylesheet" type="text/css" href="../addons/zh_yjm/template/mobile/css/index.css">
	<link rel="stylesheet" type="text/css" href="../addons/zh_yjm/template/mobile/css/jquery-weui.css">
	<link rel="stylesheet" type="text/css" href="../addons/zh_yjm/template/mobile/css/weui.min.css">
</head>
<body style="height:100%;">
<div style="position:relative;height:100%;">
	<form class='forms'>
		<div class="member_top" style="border: none;padding-top: 5rem">
			<ul id="warp">

                <li class="photo_box" style="position: relative;">

                    <input class="tx_box" type="file" id="up_img_WU_FILE_0" style="position: absolute;top:0;left:0;z-index: 99;opacity: 0"/>
                    
                    <img id="imgShow_WU_FILE_0" src="../addons/zh_yjm/template/mobile/images/tx.png" />
                   
                </li>


            </ul>
		</div>

		<ul class="zhuce_list">
			<li>
				<span>昵  称：</span>
				<input type="text" class="username" name="name">
			</li>

			<li>
				<span>手机号：</span>
				<input type="phone" name="phone" class="mobile">
			</li>
		</ul>

		<input class="sub_btn" type="button" value="注册">
	</form>
  <!-- <img style="position:absolute;bottom:0px;width:100%;height:20%;" id="bottom" src="../addons/zh_yjm/template/mobile/images/bottom.png" /> -->
</div>
</body>
<script type="text/javascript" src='../addons/zh_yjm/template/mobile/js/jquery-2.1.4.js'></script>
<script type="text/javascript" src='../addons/zh_yjm/template/mobile/js/uploadPreview.js'></script> 
<script type="text/javascript">
var imghead;
$(function () {
	$.ajax({
            type:"POST",
            url:"{$_W['siteroot']}app/index.php?i={$_W['uniacid']}&c=entry&a=site&do=Registeris&m=zh_yjm",
            async:true,
            dataType:"json",
            data:{},
            success:function(data){
            	console.log(data)
            	console.log(data.code)
            	if (data.code==502) {
            		// window.location.href="{$_W['siteroot']}app/index.php?i={$_W['uniacid']}&c=entry&do=index&m=zh_yjm"
            	}

               
            },

            error : function(data) {

                alert(data.msg);

                return false

            }
        })
})

$("#up_img_WU_FILE_0").change(function(){
            //创建FormData对象
              var data = new FormData();
              $.each($("#up_img_WU_FILE_0")[0].files, function(i,file) {
                data.append("img", file);
                //console.log("i=====索引是："+i+"file是："+file.size);
                });
              // imghead=data.get("img").name;
              console.log(data.get("img"));
              console.log(data.get("img").name);

            $.ajax({
              url:"{$_W['siteroot']}app/index.php?i={$_W['uniacid']}&c=entry&a=site&do=Uploadimg&m=zh_yjm",
              type:'POST',
              data:data,
              cache: false,
              contentType: false,    //不可缺
              processData: false,    //不可缺
              success:function(data){
                  console.log(data);
                  imghead=data
              }   
              
            })

        })

$(".sub_btn").click(function () {
	var tx=$("#up_img_WU_FILE_0").val()
	var username=$(".username").val()
	var mobile=$(".mobile").val()
	console.log(tx)
	console.log(username)
	console.log(mobile)
	console.log(imghead)

	if (tx=='') {
		alert('请上传头像')
	}else if(username==''){
		alert('请填写昵称')
	}else if(!(/^0{0,1}(13[0-9]|15[0-9]|18[0-9]|17[0-9])[0-9]{8}$/.test(mobile))){ 
		alert('手机号码格式不正确')
	}else{
		$.ajax({
            type:"POST",
            url:"{$_W['siteroot']}app/index.php?i={$_W['uniacid']}&c=entry&a=site&do=Registeru&m=zh_yjm",
            async:true,
            dataType:"json",
            data:{nickname:username,phone:mobile,avatar:imghead},
            success:function(data){
            	console.log(data)
            	console.log(data.code)
            	if (data.code==200) {
            		alert("注册成功")
            		window.location.href="{$_W['siteroot']}app/index.php?i={$_W['uniacid']}&c=entry&do=index&m=zh_yjm"
            	}

               
            },

            error : function(data) {

                alert(data.msg);

                return false

            }
        })
	}
})
$(".username").focus(function () {
  $(this).parent().css("border-bottom","0.05rem solid #0976e6")
  $(".mobile").parent().css("border-bottom","0.05rem solid #999")
})
$(".mobile").focus(function () {
  $(this).parent().css("border-bottom","0.05rem solid #0976e6")
  $(".username").parent().css("border-bottom","0.05rem solid #999")
})
</script>
</html>